<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取常量</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reflectionextension.getclassnames.html">« ReflectionExtension::getClassNames</a></li>
      <li style="float: right;"><a href="reflectionextension.getdependencies.html">ReflectionExtension::getDependencies »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.reflectionextension.html">ReflectionExtension</a></li>
    <li>获取常量</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="reflectionextension.getconstants" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionExtension::getConstants</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionExtension::getConstants</span> &mdash; <span class="dc-title">获取常量</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionextension.getconstants-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionExtension::getConstants</strong></span>(): <span class="type">array</span></div>

  <p class="para rdfs-comment">
   获取扩展中定义的常量。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionextension.getconstants-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionextension.getconstants-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回一个以常量名称为索引的数组。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionextension.getconstants-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5199">
    <p><strong>示例 #1 <span class="methodname"><strong>ReflectionExtension::getConstants()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$ext&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ReflectionExtension</span><span style="color: #007700">(</span><span style="color: #DD0000">'DOM'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$ext</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getConstants</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [XML_ELEMENT_NODE] =&gt; 1
    [XML_ATTRIBUTE_NODE] =&gt; 2
    [XML_TEXT_NODE] =&gt; 3
    [XML_CDATA_SECTION_NODE] =&gt; 4
    [XML_ENTITY_REF_NODE] =&gt; 5
    [XML_ENTITY_NODE] =&gt; 6
    [XML_PI_NODE] =&gt; 7
    [XML_COMMENT_NODE] =&gt; 8
    [XML_DOCUMENT_NODE] =&gt; 9
    [XML_DOCUMENT_TYPE_NODE] =&gt; 10
    [XML_DOCUMENT_FRAG_NODE] =&gt; 11
    [XML_NOTATION_NODE] =&gt; 12
    [XML_HTML_DOCUMENT_NODE] =&gt; 13
    [XML_DTD_NODE] =&gt; 14
    [XML_ELEMENT_DECL_NODE] =&gt; 15
    [XML_ATTRIBUTE_DECL_NODE] =&gt; 16
    [XML_ENTITY_DECL_NODE] =&gt; 17
    [XML_NAMESPACE_DECL_NODE] =&gt; 18
    [XML_LOCAL_NAMESPACE] =&gt; 18
    [XML_ATTRIBUTE_CDATA] =&gt; 1
    [XML_ATTRIBUTE_ID] =&gt; 2
    [XML_ATTRIBUTE_IDREF] =&gt; 3
    [XML_ATTRIBUTE_IDREFS] =&gt; 4
    [XML_ATTRIBUTE_ENTITY] =&gt; 6
    [XML_ATTRIBUTE_NMTOKEN] =&gt; 7
    [XML_ATTRIBUTE_NMTOKENS] =&gt; 8
    [XML_ATTRIBUTE_ENUMERATION] =&gt; 9
    [XML_ATTRIBUTE_NOTATION] =&gt; 10
    [DOM_PHP_ERR] =&gt; 0
    [DOM_INDEX_SIZE_ERR] =&gt; 1
    [DOMSTRING_SIZE_ERR] =&gt; 2
    [DOM_HIERARCHY_REQUEST_ERR] =&gt; 3
    [DOM_WRONG_DOCUMENT_ERR] =&gt; 4
    [DOM_INVALID_CHARACTER_ERR] =&gt; 5
    [DOM_NO_DATA_ALLOWED_ERR] =&gt; 6
    [DOM_NO_MODIFICATION_ALLOWED_ERR] =&gt; 7
    [DOM_NOT_FOUND_ERR] =&gt; 8
    [DOM_NOT_SUPPORTED_ERR] =&gt; 9
    [DOM_INUSE_ATTRIBUTE_ERR] =&gt; 10
    [DOM_INVALID_STATE_ERR] =&gt; 11
    [DOM_SYNTAX_ERR] =&gt; 12
    [DOM_INVALID_MODIFICATION_ERR] =&gt; 13
    [DOM_NAMESPACE_ERR] =&gt; 14
    [DOM_INVALID_ACCESS_ERR] =&gt; 15
    [DOM_VALIDATION_ERR] =&gt; 16
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionextension.getconstants-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="reflectionextension.getinientries.html" class="methodname" rel="rdfs-seeAlso">ReflectionExtension::getINIEntries()</a> - 获取ini配置</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>